package com.kotlin.myapplication.mvp.ui.start

import android.text.TextUtils
import android.view.View
import android.widget.Toast
import com.kotlin.myapplication.R
import com.kotlin.myapplication.base.BaseActivity
import com.kotlin.myapplication.bean.RegisterBean
import com.kotlin.myapplication.mvp.model.RegisterContract
import com.kotlin.myapplication.mvp.presenter.RegisterPresenter
import com.kotlin.myapplication.utils.Logger
import kotlinx.android.synthetic.main.activity_register.*

/**
 *@lil
 *@创建时间 2019/11/18 17:37
 *@描述
 */

class RegisterActivity : BaseActivity(), View.OnClickListener, RegisterContract.view {


    override lateinit var presenter: RegisterContract.registerResult


    override fun registerSuccess(result: RegisterBean) {
        Logger.log(result.toString())
    }

    override fun error(error: String) {
        Logger.log(error)
    }

    override fun initView() {
        setContentView(R.layout.activity_register)
        presenter = RegisterPresenter(this)
        btn_regist_register.setOnClickListener(this)

    }

    fun send() {
        if (TextUtils.isEmpty(et_register_phone.getText().toString().trim())) {
            Toast.makeText(this, "电话不能为空", Toast.LENGTH_SHORT).show()
            return
        }
        if (TextUtils.isEmpty(et_register_passwd.getText().toString().trim())) {
            Toast.makeText(this, "密码不能为空", Toast.LENGTH_SHORT).show()
            return
        }
        Logger.log(et_register_phone.getText().toString().trim() +
                et_register_passwd.getText().toString().trim() + "注册第二个用户")
        presenter.register(et_register_phone.getText().toString().trim(),
                et_register_passwd.getText().toString().trim(), "注册第二个用户")
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.btn_regist_register -> {
                send()
//                APPSPManager.setleadPage(true)
//                startActivity(Intent(this@RegisterActivity, MenuAcitivity::class.java))
//                finish()
            }

        }
    }

}